/**
 * 业务量登记
 * @author 孙汉斌 2011-11-28
 * 
 */
package com.zjht.gmcc.servlet.biz;

import java.io.PrintWriter;
import java.sql.PreparedStatement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;
import com.zjht.gmcc.bean.util.MyFormat;
import com.zjht.gmcc.bean.util.MyJDBC;

public class BizAmountAdd extends BaseServlet {

	private static final long serialVersionUID = 1L;

	@Override 
	protected boolean process(HttpServletRequest request, HttpServletResponse response, HttpSession session, PrintWriter out, MyJDBC myJDBC,
			String menu) throws Exception {

		String s_providerId = request.getParameter("providerid");//供应商ID
		String s_toOrder = request.getParameter("order");
		String s_orderid="";
		if ("1".equals(s_toOrder)) {// 对应合同
			 s_orderid = request.getParameter("orderid");
		}
		String s_bizDate=request.getParameter("bizDate");//业务时间
		String s_range=request.getParameter("range");//业务范围
		String s_rangeId=request.getParameter("rangeid_"+s_range);
		String s_typeId=request.getParameter("typeid");//产品分类
		double money=MyFormat.formatDouble(request.getParameter("money"));//业务量
		String s_dealOper=request.getParameter("dealoper");//经办人
		String s_memo=request.getParameter("memo");//备注
		
		PreparedStatement ps=null;
		StringBuilder sql=new StringBuilder();
		sql.append("INSERT INTO BIZAMOUNT(bizid,providerid,orderid,rangeid,producttypeid,bizdate,money,dealoper,memo)");
		sql.append("VALUES(SEQ_BIZID.NEXTVAL,?,?,?,?,?,?,?,?)");
		ps=myJDBC.prepareStatement(sql);
		ps.setString(1, s_providerId);
		ps.setString(2, s_orderid);
		ps.setString(3, s_rangeId);
		ps.setString(4, s_typeId);
		ps.setString(5, s_bizDate);
		ps.setDouble(6, money);
		ps.setString(7, s_dealOper);
		ps.setString(8, s_memo);
		int flag=0;
		flag=ps.executeUpdate();
		
		ps.close();
		ps=null;
		sql=null;
		
		String tip="业务量登记";
		if (flag == 1) {
			alert(out, tip + "成功", "/biz/bizAmount.jsp");
		} else {
			errAlert(request, out, menu, tip + "失败");
		}
		return flag == 1;
	}

}
